@file:JvmName("Stu") // 修改Java引用名称，默认为报名

/**
 * java 调用默认
 * Annotion.getDevice("system")
 * Stu.getDevice("system")
 */
package linz

import javax.swing.Box

/**
 * JvmName 在属性中的使用
 */
@get:JvmName("x")
@set:JvmName("changeX")
var x: Int = 23


/**
 * JvmField 不生成set/get 直接 public
 */
@JvmField
val info: String = "information"

class User2(id: Long ) {
    @JvmField
    val ID  = id
}


@JvmOverloads // 自动生成重载函数给java调用
fun toast(name:String,sex:Char = 'M'){
    println("name:$name, sex: $sex")
}


class MyObject{
    companion object{
        @JvmField
        val TAG = "MyObject"
        @JvmStatic // 使Java和Kotlin一样调用函数
        fun callStatic(log: String) = println(" $TAG 打印 $log")
        fun callNonStatic() {}
    }
}


fun getDevice(str: String) = println(str)

class Box{}
open class  Derived(){}
class c: Derived() {

}

/**
 * 通配符
 */
//fun boxDerived(value: Derived): Box<@JvmWildcard Derived> = Box(value)
// is translated to
// Box<? extends Derived> boxDerived(Derived value) { ... }

//fun unboxBase(box: Box<@JvmSuppressWildcards Base>): Base = box.value
// is translated to
// Base unboxBase(Box<Base> box) { ... }


fun main() {
    MyObject.callStatic("=========")
    MyObject.callNonStatic() // Java 不能这样调用

}



